package com.tedu.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.tedu.dao.IProductDao;
import com.tedu.model.Product;
import com.tedu.service.IProductService;
@Service
public class ProductService implements IProductService {
	private IProductDao productDao;
	@Resource
	public void setProductDao(IProductDao productDao) {
		this.productDao = productDao;
	}

	@Override
	public void add(Product product) {
		// TODO Auto-generated method stub
		productDao.add(product);
	}

	@Override
	public void delete(int id) {
		// TODO Auto-generated method stub
		productDao.delete(id);
	}
	

	@Override
	public void update(Product product) {
		// TODO Auto-generated method stub
		productDao.update(product);
	}

	@Override
	public Product load(int id) {
		// TODO Auto-generated method stub
		return productDao.load(id);
	}

	@Override
	public List<Product> list() {
		// TODO Auto-generated method stub
		return productDao.list();
	}

	@Override
	public List<Product> listAllProduct() {
		// TODO Auto-generated method stub
		return productDao.listAllProduct();
	}
	
	@Override
	public Product productItem(int id) {
		// TODO Auto-generated method stub
		return productDao.productItem(id);
	}
	
	//------------------------------狄克
		@Override
	public void alldelete(int id) {
		// TODO Auto-generated method stub
		productDao.alldelete(id);
	}
		//------------------------------狄克
		@Override
	public List<Product> listCategoryProduct(int id) {
		// TODO Auto-generated method stub
		return productDao.listCategoryProduct(id);
	}	
		//------------------------------狄克
		@Override
	public List<Product> selectProductsName(String str) {
		// TODO Auto-generated method stub
		return productDao.selectProductsName(str);
	}
		//------------------------------狄克
		@Override
	public List<Product> selectProductsStatus(int str) {
		// TODO Auto-generated method stub
		return productDao.selectProductsStatus(str);
	}
		//------------------------------狄克
		@Override
	public List<Product> selectProductsCategory(String str) {
		// TODO Auto-generated method stub
		return productDao.selectProductsCategory(str);
	}
		//------------------------------狄克
		@Override
	public List<Product> selectProductsDiscount(Double str) {
		// TODO Auto-generated method stub
		return productDao.selectProductsDiscount(str);
	}
////////////////////////////
		//新项目
		@Override
		public List<Product> listAllProductByFeature(int status) {
			return productDao.listAllProductByFeature(status);
		}

		@Override
		public List<Product> listAllProductOfDiscount() {
			return productDao.listAllProductOfDiscount();
		}
		
		@Override
		public List<Product> fuzzyQueryAll(String condition) {
			Map<String, String> map = new HashMap<String, String>();
			map.put("product_name", "%"+condition+"%");
			map.put("product_describe", "%"+condition+"%");
			return productDao.fuzzyQueryAll(map);
		}

		@Override
		public List<Product> fuzzyQueryDiscountProducts(String condition) {
			Map<String, String> map = new HashMap<String, String>();
			map.put("product_name", "%"+condition+"%");
			map.put("product_describe", "%"+condition+"%");
			return productDao.fuzzyQueryDiscountProducts(map);
		}

		@Override
		public List<Product> fuzzyQueryByFeature(String condition, int status) {
			Map<String, Object> map = new HashMap<String, Object>();
			map.put("status", status);
			map.put("product_name", "%"+condition+"%");
			map.put("product_describe", "%"+condition+"%");
			return productDao.fuzzyQueryByFeature(map);
		}

		@Override
		public List<Product> queryByCategory(int cid) {
			return productDao.queryByCategory(cid);
		}

		@Override
		public List<Product> fuzzyQueryByCategory(int cid, String condition) {
			Map<String, Object> map = new HashMap<String, Object>();
			map.put("cid", cid);
			map.put("product_name", "%"+condition+"%");
			map.put("product_describe", "%"+condition+"%");
			return productDao.fuzzyQueryByCategory(map);
		}
		


}
